<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>违规统计</title>
    <meta name="description" content="">
    <meta name="HandheldFriendly" content="True">
    <meta name="MobileOptimized" content="320">
    <meta name="viewport" content="width=device-width, initial-scale=1, minimal-ui, user-scalable=no">
    <meta http-equiv="cleartype" content="on">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="/assets/base/slelestat/css/style.css?v={BEESCRM:$v}">
</head>
<body>
<div class="wraper">
    <div class="header clearfix">
	    <a href="javascript:history.go(-2);" class="back pull-left"> <img src="/assets/base/statistics/images/back.png"></a>
        <span class="pull-left">违规统计</span>
    </div>
	<input type="hidden" id="roletypes" value="{BEESCRM:$roleType}">
	<input type="hidden" id="number" value="{BEESCRM:$number}">
    <div class="container nomargtop">
        <p class="title">违规次数<a href="javascript:;" class="pull-right select">筛选</a></p>

        <table class="table text-center">
            <thead class="bg-blue">
            <tr>
                <td id="type-name">班级</td>
                <td>次数</td>
                <td>时间</td>
            </tr>
            </thead>
            <tbody id="table_body">
            <tr>
                <td colspan="3" align="center" style="color:#ccc;height: 200px;">暂无数据</td>
            </tr>

            </tbody>
        </table>
    </div>

    <div class="pop-box" id="pop-select">
        <if condition="$roleType gt 2">
            <div class="lists">
                <select id="college">
                    <option value="0" selected>请选择学院</option>
                    <volist name="selector" id="vo">
                        <option value="{BEESCRM:$vo['id']}">{BEESCRM:$vo['name']}</option>
                    </volist>
                </select>
                <span class="triangle"></span>
            </div>
            <!--<div class="lists">
                <select id="grade">
                    <option value="0" selected>请选择年级</option>
                </select>
                <span class="triangle"></span>
            </div>
            <div class="lists">
                <select id="major">
                    <option value="0" selected>请选择专业</option>
                </select>
                <span class="triangle"></span>
            </div>
            <div class="lists">
                <select id="class" class="js_class">
                    <option value="0" selected>请选择班级</option>
                </select>
                <span class="triangle"></span>
            </div>-->
            <else />
            <div class="lists">
                <select class="js_class">
                    <option value="0" selected>请选择班级</option>
                    <volist name="selector" id="vo">
                        <option value="{BEESCRM:$vo['id']}">{BEESCRM:$vo['name']}</option>
                    </volist>
                </select>
                <span class="triangle"></span>
            </div>
        </if>
        <div class="lists">
            <select id="select_time">
                <option value="0" selected>请选择时间段</option>
                <option value="7">最近7天</option>
                <option value="15">最近15天</option>
                <option value="30">最近30天</option>
            </select>
            <span class="triangle"></span>
        </div>
        <div class="btn-box">
            <a href="javascript:;" class="btn bg-blue" id="select_commit">筛选</a>
        </div>
    </div>
</div>
</body>
<script type="text/javascript" src="/assets/public/jquery/jquery-2.1.0.min.js"></script>
<script src="/assets/base/electricity/js/jq.utils.js"></script>
<script src="/assets/bower_components/sweetalert/lib/sweet-alert.min.js"></script>
<link rel="stylesheet" href="/assets/bower_components/sweetalert/lib/sweet-alert.css">
<script type="text/javascript" src="/assets/base/slelestat/js/search.js"></script>
<script>
    //点击筛选按钮
    $('.select').click(function(){
        $('#pop-select').show();
    });

    //初次加载页面请求数据接口
    $(function () {
	    var xh = $('#number').val();
        getData(30,0,0,0,0,xh);
	    var role = $("#roletypes").val();
	    if(role > 2){
		    $("#type-name").html("学院");
	    }else if(role < 3){
		    $("#type-name").html("班级");
	    }else{
		    $("#type-name").html("班级");
	    }
    });


    //点击确定筛选按钮
    $(document).on('click','#select_commit',function () {
	    var xh = $('#number').val();
        var collegeId = $('#college').find('option:selected').val();
        var gradeId = $('#grade').find('option:selected').val();
        var majorId = $('#major').find('option:selected').val();
        var classId = $('.js_class').find('option:selected').val();
        var type =  $('#select_time').find('option:selected').val();
        var timeContent = $('#select_time').find('option:selected').text();
        if(!type || type == 0){
            $.alert('error','请选择时间');
            return false;
        }
        $('#pop-select').hide();
        getData(type,collegeId,gradeId,majorId,classId,xh);
    });

    function getData(type,collegeId,gradeId,majorId,classId,xh){
        var _html = '';
        var data = {
            'type' : type,
            'collegeId' : collegeId,
            'gradeId' : gradeId,
            'majorId' : majorId,
            'classId' : classId,
	        'xh' : xh
        }
        $.ajax({
            url : '/Base/SlEleStat/ajaxGetWarnCount',
            type : 'post',
            data : data,
            dataType : 'json',
            beforeSend : function () {
                $('#databox').html('');
                $('.dataload').show();
            },
            success : function (data) {
                if(data.errCode == 0){
                    if(data.data.length != 0 && data.data != null){
                        $.each(data.data, function (index, node) {
                            _html += "<tr><td>"+node.name+"</td><td><a href='/base/SlEleStat/warnInfo'>" +node.count + "</a></td><td>" + node.create_time + "</td></tr>";
                        });
                    }else{
                        _html = '<tr><td colspan="3" align="center" style="color:#ccc;height: 200px;">暂无数据</td></tr>';
                    }

                    //将html放进tbody
                    $('#table_body').html(_html);
                }else{
                    $.alert('error',data.errMsg);
                    return;
                }
            }
        })
    }
</script>
</html>